# coding=utf-8
"""
Created on 2018年8月9日
"""
from common_base.constants import LanguageType
from common_base.error_set.alive_api_error import AliveApiError


class AliveError(AliveApiError):
    """
    """
    SUCCESS = 0
    ERROR_COMMON_REQUEST_PARAM_INVALID = 1
    ERROR_COMMON_PARSE_JSON_FAILED = 3
    ERROR_COMMON_PROTOCOL_FOR_INTERNAL_ONLY = 6
    ERROR_COMMON_PROTOCOL_FOR_EXTERNAL_ONLY = 7
    ERROR_COMMON_CMD_NOT_EXISTS = 10    
    ERROR_COMMON_DATABASE_EXCEPTION = 11
    ERROR_COMMON_UNIMPLEMENT_PROTOBUF = 21
    ERROR_COMMON_PARSE_PROTOBUF_FAILED = 22
    ERROR_COMMON_PROTOBUF_SERIALIZE_FAILED = 23
    
    ERROR_COMMON_CALL_UFO_SERVICE_FAILED = 102
    ERROR_COMMON_GET_ADDRESS = 501
    ERROR_COMMON_BALANCE_NOT_ENOUGH = 502
    ERROR_COMMON_PRKEY_NOT_FOUND = 503
    ERROR_COMMON_SEND_TX_ERROR = 504
    ERROR_COMMON_USER_INFO_ERROR = 505
    ERROR_COMMON_ORDER_INFO_ERROR = 506
    ERROR_COMMON_WITHDRAW_OVERLIMIT = 507

    ERROR_COMMON_UNKNOWN = 1000

    common_message = {
        SUCCESS: {LanguageType.CN: 'success', LanguageType.EN: 'success'},
        ERROR_COMMON_REQUEST_PARAM_INVALID: {LanguageType.CN: '参数缺失或非法:', LanguageType.EN: 'Parameter missing or illegal:'},
        ERROR_COMMON_PARSE_JSON_FAILED: {LanguageType.CN: 'JSON解析失败', LanguageType.EN: 'JSON parsing failed'},
        ERROR_COMMON_PROTOCOL_FOR_INTERNAL_ONLY: {LanguageType.CN: '权限错误, 内部接口不提供外部访问', LanguageType.EN: 'Permission error, internal interface does not provide external access'},
        ERROR_COMMON_PROTOCOL_FOR_EXTERNAL_ONLY: {LanguageType.CN: '权限错误, 外部接口不提供内部访问', LanguageType.EN: 'Permission error, external interface does not provide internal access'},
        ERROR_COMMON_CMD_NOT_EXISTS: {LanguageType.CN: '协议不存在', LanguageType.EN: 'Agreement does not exist'},
        ERROR_COMMON_CALL_UFO_SERVICE_FAILED: {LanguageType.CN: 'UFO服务调用失败', LanguageType.EN: 'UFO service call failed'},
       
        ERROR_COMMON_DATABASE_EXCEPTION: {LanguageType.CN: '数据操作异常', LanguageType.EN: 'Data operation is abnormal'},
        
        ERROR_COMMON_UNIMPLEMENT_PROTOBUF: {LanguageType.CN: '请求参数错误', LanguageType.EN: 'Parameter request error'},
        ERROR_COMMON_PARSE_PROTOBUF_FAILED: {LanguageType.CN: '请求参数错误', LanguageType.EN: 'Parameter request error'},
        ERROR_COMMON_PROTOBUF_SERIALIZE_FAILED: {LanguageType.CN: '返回参数错误', LanguageType.EN: 'Return parameter error'},
        
        ERROR_COMMON_UNKNOWN: {LanguageType.CN: '未知错误', LanguageType.EN: 'unknown error'},
    }

    common_message.update(AliveApiError.message)

    @staticmethod
    def get_message(code, language=LanguageType.CN):
        """
        """
        
        return AliveError.common_message[code][language]